package ejbcareader.utils;

import java.io.FileInputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public class PropertyHelper {
	
	private static Logger log = Logger.getLogger(PropertyHelper.class);
	
	public static String GetValue(PropertiesEnum key){
		
		return GetValue(key, "config.properties");			
	}
	
	public static String GetValue(PropertiesEnum key, String propertiesFilePath){
		
		log.debug(String.format("Getting key [%s] from file [%s]", key.toString(), propertiesFilePath));
				 		
		try {
		
			Properties prop = new Properties();
			prop.load(new FileInputStream(propertiesFilePath));			
			String keyValue = prop.getProperty(key.toString());
			
			log.debug(String.format("Got value [%s] from key [%s]", keyValue, key));
			
			return keyValue;
			
		} catch (Exception ex) {
			log.error("Error getting property...returning null as value...", ex);
		}
		return null;
	}	
}
